package com.yanqu.road.server.cmd.activity.luckyshop;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LuckyShopProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.luckyshop.LuckyShopModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_LUCKY_SHOP_GET_BIG_REWARD, desc = "领大奖")
public class LuckyShopGetBigRewardCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LuckyShopProto.LuckyShopGetBigRewardReqMsg reqMsg = LuckyShopProto.LuckyShopGetBigRewardReqMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(LuckyShopModule.class).getBigReward();
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            LuckyShopProto.LuckyShopGetBigRewardRespMsg.Builder respMsg = LuckyShopProto.LuckyShopGetBigRewardRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_LUCKY_SHOP_GET_BIG_REWARD, respMsg);
        }
    }
}
